<script lang="ts" setup>
import { markRaw } from 'vue'
import WlIconText from '../../WlIconText/WlIconText.vue'
import CAdminTable from '../CAdminTable.vue'
import { TableInfo } from '../tableInfo'
import { dbCompanies, Company } from './helpers/dbCompanies'
import DbFormContractor from './helpers/DbFormContractor.vue'

const schema: any[] = [
  { id: 'name', label: '企業名' },
  {
    id: 'statusContract',
    label: 'status',
    component: markRaw(WlIconText),
    dynamicProps: ['color', 'name', 'p_Text'],
    mode: 'edit',
    name: (val) => (val ? 'mail' : 'visibility'),
    color: (val) => (val ? 'accent' : 'primary'),
    p_Text: (val, { formData }) =>
      val
        ? 'OK'
        : formData.addressPref.endsWith('県')
        ? `${formData.addressPref}知事へ連絡`
        : `${formData.addressPref}は無視でいい`,
  },
]

const tableInfo: TableInfo<Company> = {
  schemaColumns: schema,
  db: dbCompanies,
  componentForm: markRaw(DbFormContractor),
}
</script>

<template>
  <CAdminTable :tableInfo="tableInfo" p_Title="タイトル漢字english" />
</template>
